package reply

// the following is four types of replies

// 1. pong
type PongReply struct {
}

var pongbytes = []byte("+PONG\r\n")

func (PongReply) ToBytes() []byte {
	return pongbytes
}

// 暴露一个make方法
func MakePongReply() *PongReply {
	return &PongReply{}
}

// 2. ok
type OkPeply struct {
}

var okBytes = []byte("+OK\r\n")

func (r *OkPeply) ToBytes() []byte {
	return okBytes
}

var theOkReply = new(OkPeply)

func MakeOkReply() *OkPeply {
	return theOkReply // 节约内存的方法
}

// 3. null  bulk
type NullBulkReply struct {
}

var nullBulkBytes = []byte("$-1\r\n")

func (n NullBulkReply) ToBytes() []byte {
	return nullBulkBytes
}

func MakeNullBulkReply() *NullBulkReply {
	return &NullBulkReply{}
}

// 4. empty multi bulk
type EmptyMultiBulkReply struct {
}

// bulk ==> string
// multi bulk ===> []string
// 这是回复空字符串数组的方法
var emptyMultiBulkBytes = []byte("*0\r\n")

func (e EmptyMultiBulkReply) ToBytes() []byte {
	return emptyMultiBulkBytes
}

type NoReply struct {
}

var noBytes = []byte("")

func (n NoReply) ToBytes() []byte {
	return noBytes
}
